/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.eclipse.iota.model;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.iota.IotaPackage;

/**
 * @see org.eclipse.iota.IotaPackage#getUnaryOperation()
 * @model kind="class" abstract="true"
 * @generated
 */
public abstract class UnaryOperation extends EObjectImpl implements Operation {
	
	/**
	 * Alternative constructor.
	 * @param e Operand.
	 */
	public UnaryOperation(Expression e) {
		super();
		setOperand(e);
	}
	
	/**
	 * Get the equation that owns this expression.
	 * @generated NOT
	 */
	public Equation basicGetEquation() {
		if (eContainer() instanceof Equation) return (Equation) eContainer();
		if (eContainer() instanceof Expression) return ((Expression) eContainer()).getEquation();
		return null;
	}	

	/* ---------------------------------------------------------------- *
	 * GENERATED CODE.                                                  *
	 * Do not edit below this line. If you need to edit, move it above  *
	 * this line and change the '@generated'-tag to '@generated NOT'.   *
	 * ---------------------------------------------------------------- */	
	
	/**
	 * The cached value of the '{@link #getOperand() <em>Operand</em>}' containment reference.
	 * @see #getOperand()
	 * @generated
	 * @ordered
	 */
	protected Expression operand;

	/**
	 * @generated
	 */
	public UnaryOperation() {
		super();
	}

	/**
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return IotaPackage.Literals.UNARY_OPERATION;
	}

	/**
	 * Returns the value of the '<em><b>Equation</b></em>' reference.
	 * @return the value of the '<em>Equation</em>' reference.
	 * @see org.eclipse.iota.IotaPackage#getExpression_Equation()
	 * @model transient="true" changeable="false" volatile="true" derived="true"
	 * @generated
	 */
	public Equation getEquation() {
		Equation equation = basicGetEquation();
		return equation != null && equation.eIsProxy() ? (Equation)eResolveProxy((InternalEObject)equation) : equation;
	}

	/**
	 * Returns the value of the '<em><b>Operand</b></em>' containment reference.
	 * @return the value of the '<em>Operand</em>' containment reference.
	 * @see #setOperand(Expression)
	 * @see org.eclipse.iota.IotaPackage#getUnaryOperation_Operand()
	 * @model containment="true"
	 * @generated
	 */
	public Expression getOperand() {
		return operand;
	}

	/**
	 * @generated
	 */
	public NotificationChain basicSetOperand(Expression newOperand, NotificationChain msgs) {
		Expression oldOperand = operand;
		operand = newOperand;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, IotaPackage.UNARY_OPERATION__OPERAND, oldOperand, newOperand);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * Sets the value of the '{@link org.eclipse.iota.model.UnaryOperation#getOperand <em>Operand</em>}' containment reference.
	 * @param value the new value of the '<em>Operand</em>' containment reference.
	 * @see #getOperand()
	 * @generated
	 */
	public void setOperand(Expression newOperand) {
		if (newOperand != operand) {
			NotificationChain msgs = null;
			if (operand != null)
				msgs = ((InternalEObject)operand).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - IotaPackage.UNARY_OPERATION__OPERAND, null, msgs);
			if (newOperand != null)
				msgs = ((InternalEObject)newOperand).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - IotaPackage.UNARY_OPERATION__OPERAND, null, msgs);
			msgs = basicSetOperand(newOperand, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, IotaPackage.UNARY_OPERATION__OPERAND, newOperand, newOperand));
	}

	/**
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case IotaPackage.UNARY_OPERATION__OPERAND:
				return basicSetOperand(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case IotaPackage.UNARY_OPERATION__EQUATION:
				if (resolve) return getEquation();
				return basicGetEquation();
			case IotaPackage.UNARY_OPERATION__OPERAND:
				return getOperand();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case IotaPackage.UNARY_OPERATION__OPERAND:
				setOperand((Expression)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case IotaPackage.UNARY_OPERATION__OPERAND:
				setOperand((Expression)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case IotaPackage.UNARY_OPERATION__EQUATION:
				return basicGetEquation() != null;
			case IotaPackage.UNARY_OPERATION__OPERAND:
				return operand != null;
		}
		return super.eIsSet(featureID);
	}

}
